{% load staticfiles %}
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">

    <meta name="keywords" content="{% block keywords %}{% endblock %}">
    <meta name="description" content="{% block description %}{% endblock %}">

    <link href="{% static 'xadmin/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/font-awesome/css/font-awesome.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/css/plugins/iCheck/custom.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/css/animate.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/css/style.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/layui/css/layui.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/css/cms.css' %}" rel="stylesheet">
    <link href="{% static 'xadmin/layui/dtree/font/dtreefont.css' %}" rel="stylesheet" media="all">
    <link href="{% static 'xadmin/layui/dtree/dtree.css' %}" rel="stylesheet" media="all">
    <link href="{% static 'xadmin/css/plugins/toastr/toastr.min.css' %}" rel="stylesheet" media="all">
</head>

<body style="background-color: white;">
    <div class="container">
        <ul class="lanmu-info info dtree" id="lanmu-info" data-id="0">

        </ul>
{#        <div class="row" style="margin-top:20px;">#}
{#            <div style="width: 500px;min-height: 500px;margin:0 auto;">#}
{#                <button type="button" class="btn btn-sm btn-primary" onclick="article_move()">提交</button>#}
{#                <button type="button" style="margin-left: 20px;" class="btn btn-sm btn-default" onclick="articles_move()">取消</button>#}
{#            </div>#}
{#        </div>#}
    </div>

    <script src="{% static 'xadmin/js/jquery-2.1.1.min.js' %}"></script>
    <script src="{% static 'xadmin/ueditor/ueditor.config.js'%}"></script>
    <script src="{% static 'xadmin/ueditor/ueditor.all.js'%}"></script>
    <script src="{% static 'xadmin/layui/layui.all.js'%}"></script>
    <script src="{% static 'xadmin/js/plugins/toastr/toastr.min.js'%}"></script>
    <script src="{% static 'xadmin/js/myjs/toastr_customer.js'%}"></script>

    <script>
        var node_tree_json = '{{ node_tree_json }}';
        if(node_tree_json != ''){
            node_tree = {{ node_tree_json | safe }}
            layui.extend({
                dtree: '{% static "xadmin/layui/dtree/dtree" %}'
            }).use(['dtree', 'layer', 'jquery'], function(){
                var dtree = layui.dtree;
                var Tree = dtree.render({
                    elem: '#lanmu-info',


                    data: node_tree,
                });
                 //dtree.chooseDataInit(Tree, "1,8");
                 //set_select();
                // 绑定节点点击
                dtree.on("node('lanmu-info')" ,function(obj){
                  //console.log(obj.param);
                  //console.log(JSON.parse(obj.param.basicData))
                  //console.log(JSON.stringify(obj.dom));
                  var n_type = JSON.parse(obj.param.basicData);
                  if(n_type.type != "" && n_type.type == 'content'){
                      //是叶子节点


                      var nodeid = obj.param.nodeId;
                      var ids = '{{ ids }}';
                      layer.confirm('要转移到该栏目吗?', function(index){
                          layer.close(index);
                          $.ajax({
                              url: '{% url "articlesmove" %}?siteid={{ siteid }}',
                              type: 'post',
                              dataType: 'json',
                              data: {'nodeid': nodeid, "articleids": ids, 'csrfmiddlewaretoken': '{{ csrf_token }}'},
                              success: function(bk){
                                    if(bk.status == '200'){
                                        layer.alert(bk.msg, function(){
                                            parent.window.location.reload();
                                        });
                                    }
                                    else{
                                        layer.alert(bk.msg, {icon: 3});
                                    }
                              }
                          })
                      })

                  }
                });
            });
        }





    </script>
</body>

</html>